package com.company.gas.service.impl;

import com.company.gas.mapper.StaffMapper;
import com.company.gas.pojo.Staff;
import com.company.gas.service.IStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;
/**
 * @author: Li Guangdi
 *
 */
@Service
public class StaffServiceImpl implements IStaffService {

    @Autowired
    private StaffMapper staffMapper;

    @Override
    public List<Staff> queryStaffList() {
        List<Staff> staffList = staffMapper.selectAll();
        for(Staff staff : staffList){
            System.out.println(staff);
        }
        return staffList;
    }

    @Override
    public Staff queryStaffById(String staffId) {
        Staff staff = staffMapper.queryStaffById(staffId);
        System.out.println(staff);
        return staff;
    }

    @Override
    public int addStaff(String staffId, String staffName, String department,String position, String staffPhone, BigDecimal salary, Integer flag, String createBy, String modifyBy) {
        staffMapper.addStaff(staffId,staffName, department,position,staffPhone,salary,flag,createBy,modifyBy);
        return 1;
    }

    @Override
    public int updateStaff(String staffId, String staffName, String department, String position,String staffPhone, BigDecimal salary, Integer flag, String modifyBy) {
        staffMapper.updateStaff(staffId,staffName,department,position,staffPhone,salary,flag,modifyBy);
        return 1;
    }

    @Override
    public int deleteStaff(String staffId) {
        staffMapper.deleteStaff(staffId);
        return 1;
    }
}
